import 'package:dart_bean/field_info.dart';
import 'package:dart_bean/generator.dart';
import 'package:dart_bean/util/error_tip.dart';
import 'package:dart_bean/util/field_feature.dart';

class UnsupportedTypeAliseChecker extends FieldFeature {
  static final it = UnsupportedTypeAliseChecker._();

  UnsupportedTypeAliseChecker._();

  @override
  String? getConvert(FieldInfo field) {
    _checkTypeAliseError(field, field.type);
    return null;
  }

  @override
  String? mergeToJsonRightValue(FieldInfo field, String instance, String type) {
    _checkTypeAliseError(field, field.type);
    return null;
  }

  void _checkTypeAliseError(FieldInfo field, String type) {
    if (type.contains('.')) {
      onError('$unsupportedTypeAliseError\n${fieldErrorInfo(field)}');
    }
  }
}
